﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Castle.Windsor;

namespace RushTracker.Core.Util
{
    public static class IoC
    {
        private static IWindsorContainer _container;

        public static IWindsorContainer Container
        {
            get
            {
                if (_container == null)
                {
                    throw new InvalidOperationException("Container has not been initialized");
                }

                return _container;
            }
        }

        public static bool IsInitialized
        {
            get { return _container != null; }
        }

        public static void Initialize(IWindsorContainer container)
        {
            _container = container;
        }

        public static T Resolve<T>()
        {
            return _container.Resolve<T>();
        }

        public static object Resolve(Type t)
        {
            return _container.Resolve(t);
        }
    }
}
